//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/.
// 			VisualNovelToolkit		     /_/_/_/_/_/.
// Copyright ©2013 - Sol-tribe.	/_/_/_/_/_/_/_/_/_/.
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/.
using UnityEngine;
using System.Collections;

namespace ViNoToolkit{

	/// <summary>
	/// Color Utility class.
	/// </summary>
	static public class ColorUtil {
		
		static public string BeginColorTag( Color col ){
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			string hexColStr = GetHexColorString( col );
			sb.Append( "<color=" );
			sb.Append( hexColStr );
			sb.Append( ">");
			return sb.ToString();
		}

		static public string EndColorTag(){
			return "</color>";
		}

		static public string GetHexColorString( Color col ){
		 	int r = (int)( col.r * 255f );		
		 	int g = (int)( col.g * 255f );		
		 	int b = (int)( col.b * 255f );		
			string hexCol = "#" + r.ToString( "x2" ) + g.ToString( "x2" ) + b.ToString( "x2" );
			return hexCol;
		}	
		
		static public string GetHtmlTagStrippedText( string str ){
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			bool append = true;
			for(int i=0;i<str.Length;i++){
				if( str[ i ] == '<' ){
					append = false;
				}
				else if( str[ i ] == '>' ){
					append = true;
					continue;
				}
				if( append ){
					sb.Append( str[ i ] );
				}
			}
			return sb.ToString();
		}

	}
}
